feat(mcp): add SSE transport support for MCP client (salvage #19135)#21227
Merged
Conversation
Add support for MCP servers using the SSE transport protocol
(SseServerTransport) alongside the existing Streamable HTTP and stdio
transports. Many MCP servers use SSE (GET /sse + POST /messages/)
which was previously unsupported -- the client silently fell back to
Streamable HTTP, causing 10s connection timeouts.
Changes:
- Import mcp.client.sse.sse_client with graceful fallback
- Check config.get('transport') == 'sse' in _run_http() to select
the SSE transport path with proper timeout handling
- Read transport type from config in get_mcp_status() instead of
hardcoding 'http' for URL-based servers
- Update docstring, example config, and feature list
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
unresolved-import |
1 |
First entries
tools/mcp_tool.py:201: [unresolved-import] unresolved-import: Cannot resolve imported module `mcp.client.sse`
✅ Fixed issues (1):
| Rule | Count |
|---|---|
invalid-assignment |
1 |
First entries
tools/mcp_tool.py:2978: [invalid-assignment] invalid-assignment: Invalid subscript assignment with key of type `Literal["sampling"]` and value of type `dict[str, int]` on object of type `dict[str, str | int]`
Unchanged: 3941 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
1 task
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #19135 via salvage.
Summary
_run_http()previously forcedStreamableHTTPTransportfor all URL-based MCP servers; servers using SSE transport (GET /sse+POST /messages/) hung forconnect_timeout. Addstransport: sseopt-in inmcp_servers:config, importsmcp.client.sse.sse_clientwith graceful fallback if the installedmcppackage is too old.get_mcp_status()also now reports the actual transport instead of hardcodinghttp.Validation
scripts/run_tests.sh tests/tools/test_mcp_tool.py→ 182 passed.Verified
mcp.client.sse.sse_clientimports in the current venv.Original author: @andrewhosf.